package com.hexiang.validator;

import com.hexiang.domain.vo.BookRequestVO;
import org.springframework.stereotype.Component;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Arrays;
import java.util.List;

@Component
public class AuthorValidator implements ConstraintValidator<AuthorRestrict, BookRequestVO> {

    List<String> authors = Arrays.asList("Santideva", "Marie Kondo", "Martin Fowler", "mkyong");

    @Override
    public boolean isValid(BookRequestVO bookRequestVO, ConstraintValidatorContext context) {

        return authors.contains(bookRequestVO.getAuthor());

    }
}
